package com.lmq.SegretionInterface.pro;



public class examplePro01 {
    public static void main(String[] args) {
        A a = new A();
        a.depend1(new B());
        a.depend2(new B());
        a.depend3(new B());

        C c = new C();
        c.depend1(new D());
        c.depend4(new D());
        c.depend5(new D());

    }

}

interface  Interface1{
    void oper1();


}
interface  Interface2{
    void oper2();
    void oper3();
}
interface  Interface3{
    void oper4();
    void oper5();
}


class B implements Interface1,Interface2{
    @Override
    public void oper1() {
        System.out.println("B 实现了opr1");
    }

    @Override
    public void oper2() {
        System.out.println("B 实现了opr2");

    }

    @Override
    public void oper3() {
        System.out.println("B 实现了opr3");

    }


}
class D implements Interface1, Interface3{

    @Override
    public void oper1() {
        System.out.println("D 实现了opr1");

    }

    @Override
    public void oper4() {
        System.out.println("D 实现了opr4");

    }

    @Override
    public void oper5() {
        System.out.println("D 实现了opr5");

    }
}

class A {
    public void depend1(Interface1 i){
        i.oper1();
    }
    public void depend2(Interface2 i){
        i.oper2();
    }
    public void depend3(Interface2 i){
        i.oper3();
    }

}

class C {
    public void depend1(Interface1 i){
        i.oper1();
    }
    public void depend4(Interface3 i){
        i.oper4();
    }
    public void depend5(Interface3 i){
        i.oper5();
    }

}
